package graduate.wangyaqi.Taoti;

import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.Optional;

@Service
public class TaotiService {
    @Resource
    private TaotiRepository taotiRepository;
    //保存数据
    @Transactional
    public void save(Taoti taoti){
        taotiRepository.save(taoti);
    }
    //删除数据
    public void delete(long id){taotiRepository.deleteById(id);}
    //查询数据
    public Iterable<Taoti> getAll(){
        Iterable<Taoti> taotis=taotiRepository.findAll();
        return taotis;
    }

    @GetMapping(path="/findById")
    public Optional<Taoti> findById(Long aLong){
        return taotiRepository.findById(aLong);
    }
}
